package com.platform.service.impl;

import com.platform.dao.AuditDao;
import com.platform.entity.AuditEntity;
import com.platform.service.AuditService;
import com.platform.utils.Query;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @program:
 * @Description: 会员管理:审核管理 包含未审核 及 审核通过
 * @Author: liweihai
 * @Date: Created in 2019/1/21 18:39
 */
@Service
public class AuditServiceImpl implements AuditService {
    @Autowired
    private AuditDao auditDao;

    @Override
    public List<AuditEntity> selectList(Query query) {


        return auditDao.queryList(query);
    }

    @Override
    public int save(AuditEntity entity) {
        return auditDao.saveAudit(entity);
    }

    @Override
    public int update(AuditEntity entity) {
        return auditDao.updateAudit(entity);
    }



    @Override
    public int count(Query query) {
        return auditDao.queryTotal(query);
    }

    @Override
    public AuditEntity selectById(Integer id) {
        return auditDao.queryObject(id);
    }

    @Override
    public boolean updateById(Integer id, Integer status) {
        Map<String, Object> map = new HashMap<>();
        map.put("id", id);
        map.put("status", status);
        if (status == 2) {
            AuditEntity entity = auditDao.queryObject(id);
            auditDao.save(entity);
        }
        return auditDao.update(map) > 0;
    }

    @Override
    public boolean deleteById(Integer id) {
        return auditDao.delete(id) > 0;
    }

    @Override
    public List<AuditEntity> queryList(Map<String, Object> params) {
        return null;
    }

    @Override
    public boolean deleteBatch(Integer[] ids) {
        return auditDao.deleteBatch(ids) > 0;
    }

    @Override
    public List<AuditEntity> selectListPass(Query query) {
        return auditDao.selectListPass(query);
    }

    @Override
    public AuditEntity selectPassById(Long id) {
        return auditDao.selectPassById(id);
    }

    @Override
    public int countPass(Query query) {
        return auditDao.countPass(query);
    }

    @Override
    public boolean deleteBatchPass(Integer[] ids) {
        return auditDao.deleteBatchPass(ids) > 0;
    }
    @Override
    public boolean checkAudit(Long uid) {
        return auditDao.checkAudit(uid);
    }

}
